import { constantRouterMap } from '@/router'
const user = {
  state: {
    roles: constantRouterMap,
  },

  mutations: {
    SET_ROLES: (state, roles) => {
      state.roles = roles
    }
  },

  actions: {
    setRoles({ commit }, roles) {
      if (!(Array.isArray(roles) && roles.length)) {
        throw new Error('设置的权限参数不正确');
      }
      commit('SET_ROLES', roles)
    }
  }
};

export default user
